package anshe.struct
{
	import anshe.inface.IStruct;
	
	public class UserInfo extends Object implements IStruct
	{
		public var userName:String	= "";	//	用户名
		public var userNick:String	= "";	//	用户显示名（去掉 Guest_ 后的部份）
		public var userID:String	= "";	//	用户 ID 号，来自于服务器端
		public var imvuID:String	= "";	//	用户的 IMVU ID 号
		public var userFace:String	= "";	//	用户头像地址
		public var userData:String	= "";	//	用户性别等相关信息的文字串
		public var isGirl:Boolean	= false;	//	是否为女性

		public function set name(str:String):void
		{
			var ex:ExUserNames = new ExUserNames(str);
			
			this.userName = ex.userName;
			this.userNick = ex.dispName;
			this.userID = "" + Math.floor(Math.random() * 0xFFFFFF);
			this.imvuID = "" + Math.floor(Math.random() * 0xFFFFFF);
		}
		
		public final function fromObject(obj:Object):IStruct
		{
			this.userName = obj.uName;
			this.userNick = obj.uNick;
			this.userID = obj.playerId;
			this.imvuID = obj.imvuID;
			this.userFace = obj.uFace;
			this.userData = obj.uData;
			this.isGirl = obj.isGirl;
			
			UpdataFromObject(obj);

			return this;
		}
		
		public final function toObject():Object
		{
			var obj:Object = new Object();
			
			obj.uName = this.userName;
			obj.uNick = this.userNick;
			obj.playerID = this.userID;
			obj.imvuID = this.imvuID;
			obj.uFace = this.userFace;
			obj.uData = this.userData;
			obj.isGril = this.isGirl;
			
			UpdataToObject(obj);
			
			return null;
		}

		public function toString():String
		{
			return	" userName: " + this.userName +
					" userNick: " + this.userNick +
					" userID: " + this.userID +
					" imvuID: " + this.imvuID +
					" userFace: " + this.userFace +
					" userData: " + this.userData +
					" isGirl: " + this.isGirl;
		}
		
		//---------------------------------------------------
		
		//	由子类进行补充,将需要赋值的变量继续赋值
		protected function UpdataFromObject(obj:Object):void
		{			
		}
		
		//	由子类进行补充,将需要转换成为 Object 的对象直接进行转换
		protected function UpdataToObject(obj:Object):void
		{			
		}
	}
}